﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01.单例模式
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Counter counter1 = new Counter();
            //Counter counter2 = new Counter();

            //Counter counter1 = Counter.GetSingleton();
            //Counter counter2 = Counter.GetSingleton();

            for (int i = 0; i < 10; i++)
            {
                Task.Factory.StartNew(() =>
                {
                    //Counter counter1 = Counter.GetSingleton();  //缺陷：满足不了多线程
                    //Counter counter2 = Counter.GetSingleton();

                    //Counter counter1 = Counter.Instance;
                    //Counter counter2 = Counter.Instance;

                    //Counter counter1 = Counter.Singleton;
                    //Counter counter2 = Counter.Singleton;

                    //Counter counter1 = Counter.Singleton2;
                    //Counter counter2 = Counter.Singleton2;

                    //Counter counter1 = Counter.LazyInstance;
                    //Counter counter2 = Counter.LazyInstance;
                });
            }

            //Counter counter1 = Counter.Instance;
            //Counter counter2 = Counter.Instance;

            //Counter counter1 = Counter.Singleton;
            //Counter counter2 = Counter.Singleton;

            //Counter counter1 = Counter.Singleton2;
            //Counter counter2 = Counter.Singleton2;

            //Counter counter1 = Counter.LazyInstance;
            //Counter counter2 = Counter.LazyInstance;

            Console.ReadKey();
        }
    }
}
